package cn.pw.test.com.news.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import cn.pw.test.com.news.R;
import cn.pw.test.com.news.adapter.ArticleHistoryAdapter;
import tech.com.commoncore.base.BaseTitleActivity;
/**
 * @deprecated
 */
//@Route(path = PathManage.NEWS_ARTICLE_HISTORY)
public class ArticleHistoryActivity extends BaseTitleActivity {
    private SmartRefreshLayout smartRefresh;
    private RecyclerView contentRecycler;
    private ArticleHistoryAdapter historyAdapter;

//    private List<ArticleHistoryEntity> historyEntities;

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText(R.string.news_string_article_history);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_article_history;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        smartRefresh = findViewById(R.id.smart_refresh_layout);
        contentRecycler = findViewById(R.id.content_recycler_view);

        historyAdapter = new ArticleHistoryAdapter(R.layout.news_layout_item_article_history);
        contentRecycler.setLayoutManager(new LinearLayoutManager(mContext));
        contentRecycler.setAdapter(historyAdapter);

//        smartRefresh.setOnRefreshListener(new OnRefreshListener() {
//            @Override
//            public void onRefresh(RefreshLayout refreshLayout) {
//                requestData();
//            }
//        });

//        if (historyEntities == null) {
//            smartRefresh.autoRefresh();
//        }
    }

//    private void requestData() {
//        historyEntities = SQLGlobal.getImp().inquireArticleHistory();
//        smartRefresh.finishRefresh();
//
//        if (historyEntities != null && !historyEntities.isEmpty()) {
//            historyAdapter.replaceData(historyEntities);
//            historyAdapter.notifyDataSetChanged();
//        }
//    }
}
